package main

import (
	"MedicalTreatment/DepartmentAPI"
	"MedicalTreatment/DiagnosisApi"
	"MedicalTreatment/DocketAPI"
	"MedicalTreatment/Drug/DrugAPI"
	"MedicalTreatment/Login"
	"MedicalTreatment/PatientAPI"
	"MedicalTreatment/Register"
	"MedicalTreatment/RoomAPI"
	"MedicalTreatment/global"
	"MedicalTreatment/model"
	"fmt"
	"github.com/gin-gonic/gin"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
)

func main() {
	dsn := "root:123456@tcp(127.0.0.1:3306)/mybaby?charset=utf8mb4&parseTime=True&loc=Local"
	db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})
	if err != nil {
		fmt.Print(err)
	}
	err = db.AutoMigrate(model.Patient{}, model.Docket{}, model.Register{}, model.Department{}, model.DepDoc{}, model.Drug{}, model.Result{},
		model.DrugList{}, model.Room{}, model.Bed{}, model.InpatientInquiry{}, model.RegisterText{})
	if err != nil {
		panic(err)
	}

	global.DB = db
	global.Router = gin.Default()
	PatientAPI.Patient(global.Router)
	DocketAPI.DocketMang(global.Router)
	DepartmentAPI.Department(global.Router)
	Register.RegApi(global.Router)
	DrugAPI.DrugApi(global.Router)
	DiagnosisApi.DiagnosisApi(global.Router)
	RoomAPI.RoomCall(global.Router)
	Login.LoginAPI(global.Router)
	global.Router.Run(":1234")

}
